1 WRANGLING

Initial pilot data were collected via Qualtrics surveys named MAG_S2_PROLIFIC-DATACOLLAR_0 and MAG_S2_PROLIFIC-DATACOLLAR_0, each presenting participants with one common graph (“block 0”, STIMULUS = B0-0) and four subsequent graphs in random order (“block 1”).

Subsequently we made minor alterations to the question wording and respose wording, and the remaining stimuli were organized in 6 blocks. Each block was collected via PROLIFIC using independent Qualtrics surveys, with the exception of a sample of respondents directly recruited from Tumblr, using a single Qualtrics surveys with randomization logic to assign each Tumblr participant to one of the six stimulus blocks.

Participants were excluded from the sample for the following reasons

  • abandoned; Finished = False and Progress < 100%
  • fails consent or pre-screening, Finished = TRUE, Progress = 100%, Q_TerminateFlag = “Screened”
  • didnot-follow-instructions free responses indicate they misinterpred the question (most commonly they describe the graph rather than their reactions/judgements/impressions of it)
  • illegible-english free responses text is largely illegible

Following wrangling, there should be 6 blocks of stimuli, each containing responses from 40 participants from prolific, and TODO responses directly from Tumblr.

############## IMPORT STIMULI FILE
df_stimuli <- read_csv("data/input/stimuli.csv", col_names = TRUE) %>% 
  mutate(
    BLOCK = as.factor(BLOCK), 
    CATEGORY = as.factor(CATEGORY),
    ID = as.factor(ID),
    MAKER_ID = as.factor(MAKER_ID)
  )

############## BUILD LABELS
ref_stimuli <- levels(df_stimuli$ID)
ref_sd_questions <- c("MAKER_DESIGN","MAKER_DATA","MAKER_POLITIC",
               "MAKER_ARGUE","MAKER_SELF","MAKER_ALIGN","MAKER_TRUST",
               "CHART_LIKE", "CHART_BEAUTY", "CHART_INTENT", "CHART_TRUST")
left <- c("professional","professional","left-leaning","confrontational",
          "altruistic","does NOT share","untrustworthy",
          "NOT at all","NOT at all", "inform", "untrustworthy")
right <- c("layperson","layperson","right-leaning","diplomatic",
           "selfish", "DOES share", "trustworthy",
           "very much", "very much", "persuade", "trusthworthy")
ref_labels <- as.data.frame(cbind(left,right))
rownames(ref_labels) <- ref_sd_questions
ref_blocks <- c("block1", "block2", "block3", "block4", "block5", "block6")


rm(left,right)


############## STUDY ID FILE
#most blocks were run as separate qualtrics surveys with diffferent recruitments in Prolific
#Tumblr was run with all blocks and randomization
df_studies <- read_csv("data/input/studies.csv", col_names = TRUE) %>%
  mutate(
    ID.Study = as.factor(ID.Study),
    Assigned.Block = as.factor(Assigned.Block),
    Distribution = as.factor(Distribution),
    Prolific.Name = as.factor(Prolific.Name),
    Qualtrics.URL = as.factor(Qualtrics.URL),
    Qualtrics.Survey = as.factor(Qualtrics.Survey),
    Sample = as.factor(Sample),
    Scope = as.factor(Scope)
)
#### RAW DATA ####################################################################
# will always be the unaltered version of imported data
# 1 row per subject 
df_raw_datacollar <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_datacollarpilot_B1.csv", col_names = TRUE)
df_raw_bluecollar <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_bluecollarpilot_B1.csv", col_names = TRUE)
df_raw_b1 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B1.csv", col_names = TRUE)
df_raw_b2 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B2.csv", col_names = TRUE)
df_raw_b3 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B3.csv", col_names = TRUE)
df_raw_b4 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B4.csv", col_names = TRUE)
df_raw_b5 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B5.csv", col_names = TRUE)
df_raw_b6 <- read_csv("data/input/CLEAN_MAG_S2_PROLIFIC_GENERAL_B6.csv", col_names = TRUE)

# drop first two rows (qualtrics_specs)
df_raw_datacollar <- df_raw_datacollar[-c(1:2),]
df_raw_bluecollar <- df_raw_bluecollar[-c(1:2),]
df_raw_b1 <- df_raw_b1[-c(1:2),]
df_raw_b2 <- df_raw_b2[-c(1:2),]
df_raw_b3 <- df_raw_b3[-c(1:2),]
df_raw_b4 <- df_raw_b4[-c(1:2),]
df_raw_b5 <- df_raw_b5[-c(1:2),]
df_raw_b6 <- df_raw_b6[-c(1:2),]

#ADD DUMMY COLS TO DATA/BLUE COLLAR PILOT DATA 
# necessary b/c pilot (block 1) did not have chart_action behavioural question
# x <- compare_df_cols(df_raw_b2, df_raw_pilot)
df_raw_pilot <- rbind(df_raw_datacollar, df_raw_bluecollar) %>% 
  mutate(
    '0_Q_B0_CHART_ACTION' = NA,
    '1_Q_B1_CHART_ACTION' = NA,
    '1_Q_B2_CHART_ACTION' = NA,
    '1_Q_B3_CHART_ACTION' = NA,
    '1_Q_B4_CHART_ACTION' = NA,
    '1_Q_B5_CHART_ACTION' = NA,
    '1_Q_B6_CHART_ACTION' = NA,
    '2_Q_B1_CHART_ACTION' = NA,
    '2_Q_B2_CHART_ACTION' = NA,
    '2_Q_B3_CHART_ACTION' = NA,
    '2_Q_B4_CHART_ACTION' = NA,
    '2_Q_B5_CHART_ACTION' = NA,
    '2_Q_B6_CHART_ACTION' = NA,
    '3_Q_B1_CHART_ACTION' = NA,
    '3_Q_B2_CHART_ACTION' = NA,
    '3_Q_B3_CHART_ACTION' = NA,
    '3_Q_B4_CHART_ACTION' = NA,
    '3_Q_B5_CHART_ACTION' = NA,
    '3_Q_B6_CHART_ACTION' = NA,
    '4_Q_B1_CHART_ACTION' = NA,
    '4_Q_B2_CHART_ACTION' = NA,
    '4_Q_B3_CHART_ACTION' = NA,
    '4_Q_B4_CHART_ACTION' = NA,
    '4_Q_B5_CHART_ACTION' = NA,
    '4_Q_B6_CHART_ACTION' = NA
  )

df_raw <- rbind(df_raw_pilot, df_raw_b1, df_raw_b2, df_raw_b3, df_raw_b4, df_raw_b5, df_raw_b6)
rm(df_raw_datacollar, df_raw_bluecollar, df_raw_b1, df_raw_b2, df_raw_b3, df_raw_b4, df_raw_b5, df_raw_b6, df_raw_pilot)
#rename incorrectly labelled millenial 
df_raw <- df_raw %>% mutate_all(funs(str_replace(., "millenial", "millennial")))

################################################################################################
#### MASTER WIDE FORMAT DATA FRAME [1 row / qualtrics submission] ################
df_data <- df_raw %>% 
  select(
    -EndDate, -IPAddress, -RecordedDate,
    -RecipientLastName, -RecipientFirstName, -RecipientEmail,
    -ExternalReference, -LocationLatitude, -LocationLongitude, 
    -DistributionChannel, -UserLanguage, -Q_RecaptchaScore,
    -P_BROWSER_Version, -P_BROWSER_Resolution, 
    -CONSENT, -ELIGIBILITY, 
    -randomize_common, -stimulus_common, #hidden q that controls common stimulus url
    -FL_14_DO, #not actually randomization order
    -contains("First Click"), -contains("Last Click"), -contains("Click Count"),
    -T_EMAIL, -T_BROWSER_Version, -T_BROWSER_Resolution, 
    -D_politicalParty_DO, 
    -ID_PROLIFIC, -ID_STUDY, -ID_SESSION #redundant to other cols 
  ) %>% 
  rename(
    duration.sec = `Duration (in seconds)`,
    EndState = End_State, 
    TerminateFlag = Q_TerminateFlag,
    Source = Status, #where the survey originated from (should not be preview or test)
    PLATFORM = Q_PLATFORM,
    ID.Qualtrics = ResponseId,
    ID.Prolific = PROLIFIC_PID,
    ID.Study = STUDY_ID,
    ID.Session = SESSION_ID,
    P_BROWSER_OS = `P_BROWSER_Operating System`,
    T_BROWSER_OS = `T_BROWSER_Operating System`,
    SCREEN_workFunction_TEXT = SCREEN_workFunction_22_TEXT, 
    SCREEN_socialMedia_TEXT = SCREEN_socialMedia_18_TEXT,
    D_politicalParty_OTHER = D_politicalParty_4_TEXT,
    D_politicsSocial = D_politicsSocial_1,
    D_politicsFiscal = D_politicsFiscal_2
 ) %>% 
  mutate(
    D_politicsSocial = as.numeric(D_politicsSocial),
    D_politicsFiscal = as.numeric(D_politicsFiscal),
    ID.Study = factor(ID.Study),
    duration.sec = as.numeric(duration.sec), #weird booleans should only be for the test generator
    duration.min = round(duration.sec/60,2),
    Progress = as.numeric(Progress), 
    D_education = factor( D_education,
                          levels = c(
                            "NA",
                            "Some high school or less",
                            "High school diploma or GED",
                            "Associates or technical degree",
                            "Some college, but no degree",
                            "Graduate or professional degree (MA, MS, MBA, PhD, JD, MD, DDS etc.)"
                          ), 
                          labels = c(
                            "NA",
                            "< HS",
                            "HS/GED",
                            "Associates",
                            "Some college",
                            "Grad/Proff"
                          )
      ),
    D_politicalParty = factor(D_politicalParty, levels = c("NA", "Other", "Independent", "Republican", "Democrat")),
    D_age = factor(D_age, 
                   levels = c("18-24 years old" ,
                              "25-34 years old" ,
                              "35-44 years old" ,
                              "45-54 years old" ,
                              "55-64 years old" ,
                              "65+ years old"   ), 
                   labels = c("18-24", "25-34","35-44","45-54","55-64","65+ years"))
  ) %>%
  rename_at(
  #REPLACE RANDOM TRAILING _1 AND _65 FROM QUALTRICS
    vars(contains('_65')), funs(sub('_65', '', .))
  ) %>% 
  rename_at(
    vars(contains('_1')), funs(sub('_1', '', .))
  ) %>% 
  rename_at(
   vars(contains('_Page Submit')), funs(sub('_Page Submit', '', .))
  ) %>% 
  rename_at( #CHANGE DETAIL QUESTION DELIMITER FOR PIVOT PURPOSES 
   vars(contains('_CHART_')), funs(sub('_CHART_', '_CHART-', .))
  ) %>% 
  rename_at( #CHANGE DETAIL QUESTION DELIMITER FOR PIVOT PURPOSES 
   vars(contains('_MAKER_')), funs(sub('_MAKER_', '_MAKER-', .))
  ) %>% 
  rename_at( #CHANGE DETAIL QUESTION DELIMITER FOR PIVOT PURPOSES 
   vars(contains('_AGE_')), funs(sub('_AGE_', '_AGE-', .))
  ) %>% 
  rename_at( #CHANGE DETAIL QUESTION DELIMITER FOR PIVOT PURPOSES 
   vars(contains('_GENDER_')), funs(sub('_GENDER_', '_GENDER-', .))
  ) %>% 
  rename_at( #CHANGE DETAIL QUESTION DELIMITER FOR PIVOT PURPOSES 
   vars(contains('_TOOL_')), funs(sub('_TOOL_', '_TOOL-', .))
   ) %>% 
  select ( #reodering
    ID.Qualtrics, ID.Prolific:ID.Session, 
    Source, Progress, Finished, EndState, TerminateFlag, 
    StartDate, duration.min, PLATFORM,
    P_BROWSER_Browser, P_BROWSER_OS, T_BROWSER_Browser, T_BROWSER_OS, 
    D_gender:D_politicsFiscal, SCREEN_workMethod:SCREEN_socialMedia_TEXT, 
    PURPOSE, FEEDBACK , 
    `0_Q_B0_ENCOUNTER`:`4_Q_B6_CHART-ACTION`
  )  %>% 
  mutate ( #set factors 
    ID.Qualtrics = factor(ID.Qualtrics),
    ID.Prolific = factor(ID.Prolific),
    # ID.Study = factor(ID.Study),
    ID.Session = factor(ID.Session),
    PLATFORM = factor(PLATFORM),
    Source = factor(Source),
    Finished = as.logical(Finished),
    TerminateFlag = factor(TerminateFlag),
    EndState = factor(EndState), 
    D_gender = factor(D_gender), 
    D_age = factor(D_age), 
    D_income = factor(D_income),
    D_employmentStatus = factor(D_employmentStatus)
  )

## JOIN STUDY ID DATA 
df_data <- dplyr::left_join(df_data, df_studies, by="ID.Study") 

#### SEGREGATE PARTICIPANTS WHO DID NOT COMPLETE ###############################
## [1 row / qualtrics submission] ################
## NOTE it is common for prolific participants to fail the 
## screening verification, and then try again but change their 
## screening verification answers (ie. one prolific ID for multiple qualrics IDs)
df_exclude <- df_data %>% 
  filter( 
    !is.na(TerminateFlag) | Finished == FALSE | EndState != "COMPLETE"  
  ) %>% 
  select(
    ID.Qualtrics, ID.Prolific, ID.Study, Assigned.Block, Scope, Source, Progress, 
    Finished, TerminateFlag, EndState,StartDate, duration.min, 
    D_gender:D_politicsFiscal, SCREEN_workMethod:FEEDBACK, Prolific.Name:Scope
  )  %>% 
  mutate(
    EndState = if_else( (Progress < 100), "abandoned", EndState),
    EndState = if_else( (str_detect(EndState,"screen")), "screened", EndState),
    EndState = if_else( (TerminateFlag == "Screened" & is.na(EndState)), "screened", EndState),
    EndState = factor(EndState)
  )

#### MASTER VALID DATA [WIDE] 1 row per qualtrics entry #########################
## [1 row / qualtrics submission] ################
df_data <- df_data %>% filter(
  ID.Qualtrics %nin% df_exclude$ID.Qualtrics
  # (Finished == TRUE ) & is.na(TerminateFlag)
) %>% mutate(
  EndState = droplevels(EndState),
  ID.Prolific = droplevels(ID.Prolific)
)

#sanity check === SHOULD BE O
#no qualtrics surveys in good data that weren't finished
print("Number of Qualtrics entries in df_data AND nofinish/excluded? [should be 0]")
## [1] "Number of Qualtrics entries in df_data AND nofinish/excluded? [should be 0]"
sum(df_data$ID.Qualtrics %in% df_exclude$ID.Qualtrics)
## [1] 0
#sanity check === SHOULD BE O
#no duplicated PROLIFIC ids in good data 
print("Number of Prolific IDs duplicated in df_data print [should be 0]")
## [1] "Number of Prolific IDs duplicated in df_data print [should be 0]"
sum(duplicated(df_data$ID.Prolific))
## [1] 0
## save subject level 
write.csv(df_data, file = "data/output/df_participants.csv", na="")

#### CHART LEVEL DATA FRAME (LONG) FOR QDA (incl demographics) ##################
#### INCLUDES PILOT DATA FROM DATACOLLAR BLUECOLLAR PROLIFIC RECRUITMENT ########
# 1 ROW / participant X GRAPH including demographics 
# UNRAVEL TO QUESTIONS
df_qda <- df_data %>% 
  # select(
  # ID.Qualtrics:ID.Study, PLATFORM,
  # contains("_Q_"), contains("loop")
# ) %>% 
  pivot_longer( #PIVOT ON stimulus
  cols = contains("_Q_"),
  names_to = c("stimulus","dummy","BLOCK","QUESTION"),
  values_to = c("value"),
  names_sep = "_"
) %>% select(-dummy) %>% 
  unite(
   BLOCK:stimulus, col="STIMULUS", sep="-", remove=FALSE
) %>% 
  mutate(
    BLOCK = factor(BLOCK),
    STIMULUS = factor(STIMULUS),
    QUESTION = str_replace_all(QUESTION,"-","_"),
    QUESTION = factor(QUESTION),
    CATEGORY = str_remove(STIMULUS,"B.-"),
    CATEGORY = factor(CATEGORY,
                  levels=c("0","4","3","2","1"),
                  labels= c("F","D","C","B","A"))
) %>% 
  select(-stimulus) %>% 
# RE-RAVEL UP TO STIMULI
  filter(!is.na(value)) %>% 
   pivot_wider(
    names_from = QUESTION,
    values_from = value 
  ) %>%  
  tidyr::unnest() %>%  # handle r coerces values to lists
  mutate(
    across(contains("MAKER_ID") | contains("MAKER_GENDER") | contains("MAKER_AGE"), factor),
    across(contains("_CONF") | contains("_LATENCY"), as.numeric),
    across(MAKER_DESIGN:MAKER_TRUST, as.numeric),
    across(CHART_LIKE:CHART_TRUST, as.numeric),
    ENCOUNTER = factor(ENCOUNTER),
    # loop_number = as.numeric(loop_number),
    # loop_number = ifelse(is.na(loop_number), 0, loop_number),
    MAKER_LATENCY = round(MAKER_LATENCY/60,2), #CHANGE TO MINS
    CHART_LATENCY = round(CHART_LATENCY/60,2) #CHANGE TO MINS
  )
#WRITE A CSV FILE AS THE BASIS FOR THE QUALITATIVE DATA ANALYSIS
write.csv(df_qda, file = "data/output/df_qda.csv", na="")


###TODO HANDLE ASSIGNING 'Assigned.Block' for Tumblr data

#### REMOVE PILOT DATA FROM DF_DATA 
## pilot data is not included in quantitative analysis, but is made available in the qda file
df_data <- df_data %>% 
  filter(Scope != "pilot") %>% 
  mutate(
    ID.Study = droplevels(ID.Study), 
    ID.Prolific = droplevels(ID.Prolific)
  ) 



########## CHECK BLOCK COUNTS 
# title = "Participants by Condition and Data Collection Modality"
# cols = c("Control Condition","Impasse Condition","Total for Period")
print("Number of abandoned/screened/rejected attempts ")
## [1] "Number of abandoned/screened/rejected attempts "
table(df_exclude$Assigned.Block, df_exclude$Scope)
##                
##                 pilot study2
##   block1          107     28
##   block2            0     28
##   block3            0     32
##   block4            0     22
##   block5            0     11
##   block6            0     18
##   RANDOM-TUMBLR     0      0
print("Number of abandoned/screened/rejected attempts by type")
## [1] "Number of abandoned/screened/rejected attempts by type"
table(df_exclude$EndState)
## 
##                  abandoned didnot-follow-instructions 
##                        152                         25 
##          failed_nonconsent          illegible-english 
##                          2                          2 
##                 low-effort                   screened 
##                         13                         54
print("Number of successful surveys")
## [1] "Number of successful surveys"
table(df_data$Assigned.Block)
## 
##        block1        block2        block3        block4        block5 
##            40            40            40            40            40 
##        block6 RANDOM-TUMBLR 
##            40             0
# cont %>% addmargins() %>% kbl(caption = title, col.names = cols) %>%  kable_classic()


# END WRANGLE MASTER WIDE DATA FRAME 
################################################################################################
################################################################################################



  
#### QUESTION LEVEL DATA FRAME (LONG) ##########################
# unravel ALL the way down to questions 
# 1 row per participant-graph-question
df_questions <- df_data %>% 
  select(
  ID.Prolific, duration.min,  Assigned.Block,
  Sample, Scope, Distribution, PLATFORM, 
  D_gender:D_politicsFiscal, 
  contains("_Q_"), contains("loop"), 
) %>% 
  pivot_longer( #PIVOT ON stimulus
  cols = contains("_Q_"),
  names_to = c("stimulus","dummy","BLOCK","QUESTION"),
  values_to = c("value"),
  names_sep = "_"
) %>% select(-dummy) %>% 
  unite(
   BLOCK:stimulus, col="STIMULUS", sep="-", remove=FALSE
) %>% 
  mutate(
    BLOCK = factor(BLOCK),
    STIMULUS = factor(STIMULUS),
    QUESTION = str_replace_all(QUESTION,"-","_"),
    QUESTION = factor(QUESTION),
    CATEGORY = str_remove(STIMULUS,"B.-"),
    CATEGORY = factor(CATEGORY,
                  levels=c("0","4","3","2","1"),
                  labels= c("F","D","C","B","A"))
) %>% 
  select(-stimulus) %>% filter(!is.na(value))


#### SD QUESTION LEVEL DATA FRAME (LONG) ##########################
# ravel up one level from questions
# 1 row per participant-question with all blocks as cols for SD qs
df_sd_questions <- df_questions %>%
  select(-BLOCK,-CATEGORY) %>% #drop block in order to work at stimulus level
  filter(QUESTION %in% ref_sd_questions) %>% 
  pivot_wider(
    names_from = STIMULUS,
    values_from = value 
  ) %>%  
  tidyr::unnest() %>%  # handle r coerces values to lists
  mutate(
    across(contains("-") , as.numeric),
    QUESTION = droplevels(QUESTION)
  )


#### MULTI-SELECT QUESTIONS  ##########################

## DF_TOOLS 
# 1 ROW per PARTICIPANT X STIMULUS X tool_id selection 
# tool_id is a multiselect field 
df_tools <- df_questions %>% 
  # select(ID.Prolific, QUESTION, value) %>%
  filter(QUESTION  %in% c("TOOL_ID", "TOOL_CONF")) %>% 
  mutate(QUESTION = fct_drop(QUESTION)) %>% 
  pivot_wider(
    names_from = QUESTION,
    values_from = value 
  ) %>% 
  separate_longer_delim(
    cols = TOOL_ID,
    delim = ","
  ) %>% 
  mutate(TOOL_ID = factor(TOOL_ID, 
                             levels = c("?", "design_basic","design_advanced", "viz_basic", "viz_advanced", "programming")),
         ID.Prolific = droplevels(ID.Prolific),
         TOOL_CONF = as.numeric(TOOL_CONF)
         ) 

## DF_ACTIONS 
# 1 ROW per PARTICIPANT X STIMULUS X chart_action selection 
# chart_action is a multiselect field 
df_actions <- df_questions %>% 
  filter(QUESTION == "CHART_ACTION") %>% 
  mutate(QUESTION = fct_drop(QUESTION)) %>% 
  separate_longer_delim(
    cols = value,
    delim = ","
  ) %>% 
  mutate(CHART_ACTION = factor(value, 
                                  levels =  c("NOTHING — just keep scrolling",
                                              "unfollow / block the source",
                                              "post a comment",
                                              "share / repost",
                                              "share / repost WITH comment",
                                              "look up more information about the topic or source"),
                                  labels =  c("nothing",
                                              "unfollow/block",
                                              "comment",  
                                              "share",
                                              "share w/ comment",
                                              "seek information")),
         ID.Prolific = droplevels(ID.Prolific)) %>% 
  select(-value,-QUESTION)

#### CHART LEVEL DATA FRAME (LONG) ##########################
# roll partway back up from questions 
# 1 row per participant X graph 
# unnest https://stackoverflow.com/questions/58035452/pivot-wider-outputs-s3-vctrs-list-of-objects
df_graphs_full <- df_questions %>% 
  pivot_wider(
    names_from = QUESTION,
    values_from = value 
  ) %>%  
  tidyr::unnest() %>%  # handle r coerces values to lists
  mutate(
    across(contains("MAKER_ID") | contains("MAKER_GENDER") | contains("MAKER_AGE"), factor),
    across(contains("_CONF") | contains("_LATENCY"), as.numeric),
    across(MAKER_DESIGN:MAKER_TRUST, as.numeric),
    across(CHART_LIKE:CHART_TRUST, as.numeric),
    ENCOUNTER = factor(ENCOUNTER),
    # loop_number = as.numeric(loop_number),
    # loop_number = ifelse(is.na(loop_number), 0, loop_number),
    MAKER_LATENCY = round(MAKER_LATENCY/60,2), #CHANGE TO MINS
    CHART_LATENCY = round(CHART_LATENCY/60,2), #CHANGE TO MINS
    MAKER_ID = factor( MAKER_ID,levels = c("business", "political", "education","news","organization","individual"))
  )

## SUBSET OF COLUMNS EXCLUDING THE FREE RESPONSES and MULTISELECT
df_graphs <- df_graphs_full %>% 
  select( !is.character)

#CHECK BLOCKS PER PARTICIPANT
# every participant should have 2 blocks
check_subject_blocks <- df_questions %>%
  group_by(ID.Prolific) %>% summarise(
    n_block = length(unique(BLOCK))
  )
print("every participant should have two blocks, [block 0 + randomly assigned block]")
## [1] "every participant should have two blocks, [block 0 + randomly assigned block]"
all(check_subject_blocks$n_block==2)
## [1] TRUE
#CHECK STIMULI PER PARTICIPANT
# every participant should have 5 graphs
check_subject_graphs <- df_questions %>% 
  group_by(ID.Prolific) %>%summarise(
    n_graphs = length(unique(STIMULUS))
  ) #each participant should have five graphs
print("every participant should have five stimuli [B0 + 4 stimuli in a block]]")
## [1] "every participant should have five stimuli [B0 + 4 stimuli in a block]]"
all(check_subject_graphs$n_graphs==5)
## [1] TRUE
#CLEANUP
rm(check_subject_blocks, check_subject_graphs, df_graphs_qda)

1.1 Graphing Functions

############## RETURNS SD STACKED AND COLORED BY BY X
## LOOP STYLE
multi_sd <- function (df, left, right, x, y, color) {

  # g <- ggplot(df, aes(y = .data[[x]], x = {{y}}, color = {{color}}))+
  g <- ggplot(df, aes(y = .data[[x]], x = .data[[y]], color = .data[[color]]))+
  geom_boxplot(width = 0.5) +
  geom_jitter(width = 0.1, alpha=0.5) +
  scale_y_continuous(limits=c(-1,101)) +
  labs(x="", y="") +
  coord_flip() +
  guides(
    y = guide_axis_manual(labels = left),
    y.sec = guide_axis_manual(labels = right)
  ) + theme_minimal()

  return(g)
}


############## RETURNS SINGLE SD 
## LOOP STYLE
single_sd <- function (df, left, right, x) {

  g <- ggplot(df, aes(y = {{x}}, x = ""))+
  geom_boxplot(width = 0.5) +
  geom_jitter(width = 0.1, alpha=0.5) +
  scale_y_continuous(limits=c(-1,101)) +
  labs(x="", y="") +
  coord_flip() +
  guides(
    y = guide_axis_manual(labels = left),
    y.sec = guide_axis_manual(labels = right)
  ) + theme_minimal()

  return(g)
}



######### RETURNS SINGLE SD
##  APPLY STYLE
plot_sd = function (data, column, type, boxplot) {
    
  ggplot(df, aes(y = .data[[column]], x="")) +
    {if(boxplot) geom_boxplot(width = 0.5) } +
    geom_jitter(width = 0.1, alpha=0.3) + 
    scale_y_continuous(limits=c(-1,101)) +
    labs(x="", y="") +
    coord_flip()  +
    {if(type == "S")
      guides(
        y = guide_axis_manual(labels = ref_labels[column,"left"]),
        y.sec = guide_axis_manual(labels = ref_labels[column,"right"])
      )} +  
    {if(type == "Q")
      guides(
        y = guide_axis_manual(labels = ref_labels[q,"left"]),
        y.sec = guide_axis_manual(labels = ref_labels[q,"right"])
      )} +  
  theme_minimal()  + 
     labs (
       caption = column
     )
}

2 PROFILING

2.1 Descriptives

dfSummary(df_data %>% select(ID.Prolific, duration.min, PLATFORM, 
                             contains("D_"), Prolific.Name:Scope, contains("SCREEN_")), 
          headings = TRUE,
          plain.ascii  = FALSE,
          style        = 'grid',
          graph.magnif = 0.85,
          varnumbers = FALSE,
          valid.col    = FALSE,
          tmp.img.dir  = "/tmp")

2.1.1 Data Frame Summary

2.1.1.1

Dimensions: 240 x 29
Duplicates: 0

Variable Stats / Values Freqs (% of Valid) Graph Missing
ID.Prolific
[factor]
1. 55914b15fdf99b1e5e44e714
2. 5622dc5ced6e5a0011c80737
3. 56d0f57421cd29000a9737e4
4. 571e332b1bdf1a00119149f2
5. 572bf2aa34b25a000edd2e73
6. 57dd186e6598aa0001992616
7. 589de7bbbb9e0f0001ac9768
8. 58ae37d8e6afe00001d36ac9
9. 5915cec595ded300017c8261
10. 594425f07ccfd00001d3f462
[ 230 others ]
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
230 (95.8%)
0
(0.0%)
duration.min
[numeric]
Mean (sd) : 42.4 (21.2)
min < med < max:
14 < 37.2 < 216.2
IQR (CV) : 24.7 (0.5)
229 distinct values 0
(0.0%)
PLATFORM
[factor]
1. Facebook
2. Instagram
3. LinkedIn
4. Tumblr
5. Twitter/X
69 (28.7%)
88 (36.7%)
8 ( 3.3%)
6 ( 2.5%)
69 (28.7%)
0
(0.0%)
D_gender
[factor]
1. Female
2. Male
3. Non-binary / third gender
4. Prefer not to say
5. Prefer to self-describe
129 (53.8%)
102 (42.5%)
7 ( 2.9%)
1 ( 0.4%)
1 ( 0.4%)
0
(0.0%)
D_gender_4_TEXT
[character]
1. Agender 1 (100.0%) 239
(99.6%)
D_race
[character]
1. White or Caucasian
2. Asian
3. Black or African American
4. Other
5. White or Caucasian,Asian
6. White or Caucasian,Black
7. White or Caucasian,Americ
8. White or Caucasian,Americ
9. White or Caucasian,Other
10. American Indian/Native Am
[ 4 others ]
148 (61.7%)
32 (13.3%)
30 (12.5%)
10 ( 4.2%)
5 ( 2.1%)
4 ( 1.7%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
1 ( 0.4%)
4 ( 1.7%)
0
(0.0%)
D_education
[factor]
1. NA
2. < HS
3. HS/GED
4. Associates
5. Some college
6. Grad/Proff
0 ( 0.0%)
4 ( 8.3%)
19 (39.6%)
25 (52.1%)
0 ( 0.0%)
0 ( 0.0%)
192
(80.0%)
D_employmentStatus
[factor]
1. A homemaker or stay-at-ho
2. Other
3. Retired
4. Student
5. Unemployed and looking fo
6. Working full-time
7. Working part-time
9 ( 3.8%)
5 ( 2.1%)
4 ( 1.7%)
15 ( 6.2%)
39 (16.2%)
126 (52.5%)
42 (17.5%)
0
(0.0%)
D_income
[factor]
1. $100,000-$149,999
2. $150,000 or more
3. $25,000-$49,999
4. $50,000-$74,999
5. $75,000-$99,999
6. Less than $25,000
7. Prefer not to say
39 (16.2%)
20 ( 8.3%)
51 (21.2%)
60 (25.0%)
31 (12.9%)
32 (13.3%)
7 ( 2.9%)
0
(0.0%)
D_work_detail
[character]
1. Unemployed
2. N/A
3. homemaker
4. Manager
5. Student
6. engineer
7. graphic designer
8. Independent Contractor
9. IT
10. Nanny
[ 206 others ]
7 ( 2.9%)
5 ( 2.1%)
3 ( 1.3%)
3 ( 1.3%)
3 ( 1.3%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
208 (87.0%)
1
(0.4%)
D_zipcode
[character]
1. 11105
2. 20149
3. 27858
4. 30019
5. 37917
6. 85210
7. 95123
8. 01830
9. 01864
10. 02050
[ 223 others ]
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
2 ( 0.8%)
1 ( 0.4%)
1 ( 0.4%)
1 ( 0.4%)
223 (92.9%)
0
(0.0%)
D_age
[factor]
1. 18-24
2. 25-34
3. 35-44
4. 45-54
5. 55-64
6. 65+ years
38 (15.8%)
91 (37.9%)
50 (20.8%)
45 (18.8%)
13 ( 5.4%)
3 ( 1.2%)
0
(0.0%)
D_politicalParty
[factor]
1. NA
2. Other
3. Independent
4. Republican
5. Democrat
0 ( 0.0%)
6 ( 2.6%)
70 (30.6%)
26 (11.4%)
127 (55.5%)
11
(4.6%)
D_politicalParty_OTHER
[character]
1. Anarchist
2. Freedom and peace party
3. Independent but anti curr
4. Libertarian
5. Moderate. I have some rep
6. Progressive
1 (16.7%)
1 (16.7%)
1 (16.7%)
1 (16.7%)
1 (16.7%)
1 (16.7%)
234
(97.5%)
D_politicsSocial
[numeric]
Mean (sd) : 32.3 (27.5)
min < med < max:
0 < 25 < 100
IQR (CV) : 43 (0.9)
62 distinct values 0
(0.0%)
D_politicsFiscal
[numeric]
Mean (sd) : 39.4 (29)
min < med < max:
0 < 40.5 < 100
IQR (CV) : 40.2 (0.7)
70 distinct values 0
(0.0%)
Prolific.Name
[factor]
1. MAG_S2_PROLIFIC_BLUECOLLA
2. MAG_S2_PROLIFIC_DATACOLLA
3. MAG_S2_PROLIFIC_GENERAL_B
4. MAG_S2_PROLIFIC_GENERAL_B
5. MAG_S2_PROLIFIC_GENERAL_B
6. MAG_S2_PROLIFIC_GENERAL_B
7. MAG_S2_PROLIFIC_GENERAL_B
8. MAG_S2_PROLIFIC_GENERAL_B
9. MAG_S2_PROLIFIC_GENERAL_B
10. MAG_S2_PROLIFIC_GENERAL_B
[ 4 others ]
0 ( 0.0%)
0 ( 0.0%)
40 (16.7%)
20 ( 8.3%)
20 ( 8.3%)
18 ( 7.5%)
22 ( 9.2%)
21 ( 8.8%)
19 ( 7.9%)
19 ( 7.9%)
61 (25.4%)
0
(0.0%)
Qualtrics.URL
[factor]
1. https://mit.co1.qualtrics\ 2. https://mit.co1.qualtrics\ 3. https://mit.co1.qualtrics\ 4. https://mit.co1.qualtrics\ 5. https://mit.co1.qualtrics\ 6. https://mit.co1.qualtrics\ 7. https://mit.co1.qualtrics\ 8. https://mit.co1.qualtrics\ 9. https://mit.co1.qualtrics 40 (16.7%)
0 ( 0.0%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
0 ( 0.0%)
0 ( 0.0%)
40 (16.7%)
40 (16.7%)
0
(0.0%)
Assigned.Block
[factor]
1. block1
2. block2
3. block3
4. block4
5. block5
6. block6
7. RANDOM-TUMBLR
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
0 ( 0.0%)
0
(0.0%)
Description
[character]
1. block1-full
2. block2-10
3. block2-fill
4. block3-20
5. block3-fill
6. block4-20
7. block4-fill
8. block5-20
9. block5-fill
10. block6-20
11. block6-fill
40 (16.7%)
20 ( 8.3%)
20 ( 8.3%)
18 ( 7.5%)
22 ( 9.2%)
21 ( 8.8%)
19 ( 7.9%)
19 ( 7.9%)
21 ( 8.8%)
20 ( 8.3%)
20 ( 8.3%)
0
(0.0%)
Distribution
[factor]
1. prolific
2. tumbr
240 (100.0%)
0 ( 0.0%)
0
(0.0%)
Qualtrics.Survey
[factor]
1. MAG_S2_PROLIFIC_GENERAL_1
2. MAG_S2_PROLIFIC_GENERAL_2
3. MAG_S2_PROLIFIC_GENERAL_3
4. MAG_S2_PROLIFIC_GENERAL_4
5. MAG_S2_PROLIFIC_GENERAL_5
6. MAG_S2_PROLIFIC_GENERAL_6
7. MAG_S2_PROLIFIC-BLUECOLLA
8. MAG_S2_PROLIFIC-DATACOLLA
9. MAG_S2_TUMBLR_ALL
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
40 (16.7%)
0 ( 0.0%)
0 ( 0.0%)
0 ( 0.0%)
0
(0.0%)
Sample
[factor]
1. blue-collar
2. data-collar
3. general-prolific
4. shared-tumblr
0 ( 0.0%)
0 ( 0.0%)
240 (100.0%)
0 ( 0.0%)
0
(0.0%)
Scope
[factor]
1. pilot
2. study2
0 ( 0.0%)
240 (100.0%)
0
(0.0%)
SCREEN_workMethod
[character]
1. btwn-50-75
2. btwn25-50
3. less-25
4. more-75
37 (15.4%)
14 ( 5.8%)
31 (12.9%)
158 (65.8%)
0
(0.0%)
SCREEN_workFunction
[character]
1. other
2. Operations
3. IT
4. Administration-PersonalAs
5. Education-Professional
6. Healthcare-Professional
7. Research
8. Data-Analysis
9. Sales-Business-Developmen
10. Finance-Accounting
[ 46 others ]
53 (22.1%)
21 ( 8.8%)
16 ( 6.7%)
14 ( 5.8%)
14 ( 5.8%)
13 ( 5.4%)
13 ( 5.4%)
10 ( 4.2%)
10 ( 4.2%)
8 ( 3.3%)
68 (28.3%)
0
(0.0%)
SCREEN_workFunction_TEXT
[character]
1. N/A
2. Student
3. unemployed
4. Unemployed
5. n/a
6. Not applicable
7. Alternative Health
8. Business services
9. Business support
10. Childcare
[ 27 others ]
6 (12.0%)
3 ( 6.0%)
3 ( 6.0%)
3 ( 6.0%)
2 ( 4.0%)
2 ( 4.0%)
1 ( 2.0%)
1 ( 2.0%)
1 ( 2.0%)
1 ( 2.0%)
27 (54.0%)
190
(79.2%)
SCREEN_socialMedia
[character]
1. Twitter,Reddit,LinkedIn
2. Facebook,Instagram,Reddit
3. Facebook,Twitter,Instagra
4. Facebook,Twitter,Youtube,
5. Facebook,Instagram,Reddit
6. Facebook,Twitter,Youtube,
7. Facebook,Twitter,Reddit,L
8. Facebook,Instagram
9. Facebook,LinkedIn
10. Facebook,Reddit,LinkedIn
[ 129 others ]
8 ( 3.3%)
7 ( 2.9%)
7 ( 2.9%)
7 ( 2.9%)
6 ( 2.5%)
6 ( 2.5%)
5 ( 2.1%)
4 ( 1.7%)
4 ( 1.7%)
4 ( 1.7%)
182 (75.8%)
0
(0.0%)
SCREEN_socialMedia_TEXT
[character]
1. 4chan
2. alt tech, to avoid exactl
3. Bluesky
4. discord
5. Discord
6. mastedons,telegram
7. Monster, GlassDoor
8. nextdoor
1 (12.5%)
1 (12.5%)
1 (12.5%)
1 (12.5%)
1 (12.5%)
1 (12.5%)
1 (12.5%)
1 (12.5%)
232
(96.7%)

2.2 Demographics

2.2.1 Total Response Time

df <- df_data

## BOXPLOT — SURVEY RESPONSE TIME 
ggplot(df_data, aes(x=fct_rev(Assigned.Block), y=duration.min, color=Assigned.Block))+
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(), alpha = 0.3) +
  coord_flip() + 
  labs( y = "Survey Response Time (mins)", x="",
        title = "TOTAL Response Time by Sample",
        subtitle = "(distributions of response times are similar across samples, as expected)") +
  theme_minimal() + theme(legend.position = "none") 

## RIDGEPLOT — SURVEY RESPONSE TIME 
ggplot(df, aes(x = duration.min, y = fct_rev(Assigned.Block), fill = fct_rev(Assigned.Block))) +
  geom_density_ridges(scale=0.8) +
  # geom_boxplot()+
  stat_pointinterval()+
  theme_ridges() +
  scale_fill_discrete(direction=-1)+
  theme_minimal() + 
  theme(legend.position = "none") +
    labs( x = "Survey Response Time (mins)", y="",
        title = "TOTAL Response Time by Sample",
        subtitle = "(distributions of response times are similar across samples, as expected)") 
## Picking joint bandwidth of 7.37

Participant response times ranged from 13.97 to 216.18 minutes, with a mean response time of 42.36 minutes.

2.2.2 Maker Page Response Time

df <- df_graphs

## BOXPLOT — MAKER RESPONSE TIME  
ggplot(df, aes(x=CATEGORY, y=MAKER_LATENCY, color=CATEGORY))+
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(jitter.width=1.5), alpha = 0.3) +
  scale_color_viridis(discrete=TRUE, option="viridis") + 
  coord_flip() + 
  labs( y = "MAKER Page Response Time (mins)", x="",
        title = "MAKER Page Response Time by Stimulus Category",
        subtitle = "(distributions of response times are similar across samples, as expected)") + 
  theme_minimal() + theme(legend.position = "none") 

## RIDGEPLOT — MAKER PAGE RESPONSE
ggplot(df, aes(x = MAKER_LATENCY, y = CATEGORY, fill = CATEGORY)) +
  geom_density_ridges(scale=0.8) +
  # geom_boxplot()+
  stat_pointinterval()+
  # theme_ridges() +
  scale_fill_viridis(discrete=TRUE, option="viridis") + 
  theme_minimal() + 
  theme(legend.position = "none") +
    labs( x = "MAKER Page Response Time (mins)", y="",
        title = "MAKER Page Response Time by Stimulus Category",
        subtitle = "(distributions of response times are similar across samples, as expected)") 
## Picking joint bandwidth of 0.385

Maker page response times ranged from 0.46 to 19.83 minutes, with a mean response time of 2.7 minutes.

2.2.3 Chart Page Response Time

df <- df_graphs

## BOXPLOT — MAKER RESPONSE TIME  
ggplot(df, aes(x=CATEGORY, y=CHART_LATENCY, color=CATEGORY))+
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(jitter.width=1.5), alpha = 0.3) +
  scale_color_viridis(discrete=TRUE, option="viridis") + 
  coord_flip() + 
  labs( y = "CHART Page Response Time (mins)", x="",
        title = "CHART Page Response Time by Stimulus Category",
        subtitle = "(distributions of response times are similar across samples, as expected)") +
  theme_minimal() + theme(legend.position = "none") 

## RIDGEPLOT — MAKER PAGE RESPONSE
ggplot(df, aes(x = CHART_LATENCY, y = CATEGORY, fill = CATEGORY)) +
  geom_density_ridges(scale=0.8) +
  # geom_boxplot()+
  stat_pointinterval()+
  # theme_ridges() +
  scale_fill_viridis(discrete=TRUE, option="viridis") + 
  theme_minimal() + 
  theme(legend.position = "none") +
    labs( x = "CHART Page Response Time (mins)", y="",
        title = "CHART Page Response Time by Stimulus Category",
        subtitle = "(distributions of response times are similar across samples, as expected)") 
## Picking joint bandwidth of 0.246

Chart page response times ranged from 0.19 to 20.21 minutes, with a mean response time of 1.7 minutes.

2.2.4 Education

# EDUCATION by SAMPLE
ggplot(data = df_data, aes( x = Assigned.Block, fill = D_education )) +
  geom_bar(position = "stack") +
  labs( title = "EDUCATION by Sample",
        subtitle = "Expect similiar across samples", x = "") +
  theme_minimal() +
  # easy_remove_x_axis() +
  easy_add_legend_title("Sample")

2.2.5 Age

# AGE by SAMPLE
ggplot(data = df_data, aes( x = Assigned.Block, fill = fct_rev(D_age) )) +
  geom_bar(position = "stack") +
  labs( title = "AGE by Sample", subtitle = "Expect similiar across samples", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis", direction=-1) + 
  theme_minimal() +
  easy_add_legend_title("")

2.2.6 Political Values

df <- df_graphs

# FISCAL POLITICAL SAMPLE

leftside <- rep("left-leaning", length(ref_blocks))
rightside <- rep("right-leaning", length(ref_blocks))
g <- ggplot(df_data, aes(x=fct_rev(Assigned.Block), y=D_politicsFiscal, color=Assigned.Block)) +
  geom_boxplot(position=position_dodge(0.9), width = 0.5)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.3) +
  labs( title = "FISCAL VALUES by Sample",
        subtitle = "(expect similar values across samples)",
         y = "Fiscal Politics", x = "") +
  easy_add_legend_title("Sample") +
  theme_minimal() +
  coord_flip()
g + guides(
  y = guide_axis_manual(
  breaks = ref_blocks,
  labels = leftside
  ),
  y.sec = guide_axis_manual(
  breaks = ref_blocks,
  labels = rightside
))

# SOCIAL POLITICAL SAMPLE

leftside <- rep("left-leaning", length(ref_blocks))
rightside <- rep("right-leaning", length(ref_blocks))
g <- ggplot(df_data, aes(x=fct_rev(Assigned.Block), y=D_politicsSocial, color=Assigned.Block)) +
  geom_boxplot(position=position_dodge(0.9), width = 0.5)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.3) +
  labs( title = "SOCIAL VALUES by Sample",
        subtitle = "(expect similar values across samples)",
         y = "Social Politics", x = "") +
  easy_add_legend_title("Sample") +
  theme_minimal() +
  coord_flip()
g + guides(
  y = guide_axis_manual(
  breaks = ref_blocks,
  labels = leftside
  ),
  y.sec = guide_axis_manual(
  breaks = ref_blocks,
  labels = rightside
))

r_politics <- nrow(df_data %>% filter(D_politicsSocial >= 50)) / nrow(df_data)
l_politics <- nrow(df_data %>% filter(D_politicsSocial < 50)) / nrow(df_data)
r_fiscal <- nrow(df_data %>% filter(D_politicsFiscal >= 50)) / nrow(df_data)
l_fiscal <- nrow(df_data %>% filter(D_politicsFiscal < 50)) / nrow(df_data)
 
rm(g)

Across all six samples (n=40/sample) participants tended to report center-left leaning social values (M = 32.3, SD = (27.46) on a [0,100] scale); with slightly more central fiscal values (M = 39.43), SD = (29.03).

Overall, 71.25% of respondents identify with left-leaning social values (vs) 28.75% identifying as right-leaning; while 57.08% of respondents reported left-leaning fiscal values (vs) 42.92% identify as right-leaning.

2.2.7 Politcal Affiliation

# POLITICAL PARTY
ggplot(data = df_data, aes( fill = D_politicalParty, x = Assigned.Block )) +
  geom_bar(position = "stack") +
  labs( title = "POLITICAL PARTY by Sample",
        subtitle = "Expect similiar across samples", x = "") +
  theme_minimal() +
  easy_add_legend_title("")

2.2.8 Platform Choice

#PLATFORM CHOICE
ggplot( df_data, aes( x = Assigned.Block, fill = PLATFORM)) +
  geom_bar(position = "stack") +
  labs( title = "PLATFORM CHOICE by Sample",
        subtitle = "Expect similiar across samples", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") + 
  easy_add_legend_title("") +
  theme_minimal()

3 ATTRIBUTIONS

3.1 MAKER ID

3.1.1 Maker ID by Stimulus

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = fct_rev(STIMULUS), fill = MAKER_ID)) +
  geom_bar(position = "fill") +
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  labs( title = "MAKER ID by Stimulus (grouped by CATEGORY) ",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  coord_flip()+
  easy_add_legend_title("") +
  theme_minimal()

3.1.2 Maker ID by Category

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = CATEGORY, fill = MAKER_ID)) +
  geom_bar(position = "stack") +
  labs( title = "MAKER ID by Stimulus Category",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  coord_flip()+
  easy_add_legend_title("") +
  theme_minimal()

3.1.3 Maker ID & Confidence by Stimulus

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER ID AND CONFIDENCE ##############
# MAKER_ID by Sample and BEHAVIOR 
a <- ggplot (df, aes( x = fct_rev(STIMULUS), fill = MAKER_ID)) + 
  # geom_bar(width = 0.5, position = position_dodge(0.5)) +
  geom_bar(position = "fill", width = 0.8) + 
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# MAKER_CONFIDENCE by IDENTIFICATION  
b <- ggplot(df, aes( x = fct_rev(STIMULUS), y = MAKER_CONF, color = MAKER_ID)) + 
  geom_boxplot(position=position_dodge(0.9), width = 0.5)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.4) +
  scale_color_viridis(discrete=TRUE, option="viridis") +
  labs (title = "") +
  labs (x = "") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER ID & CONFIDENCE by Stimulus',
  subtitle = '',
  caption = ''))

###################################################
rm(a,b,p)

3.1.4 Maker ID & Confidence

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER ID AND CONFIDENCE ##############
# MAKER_ID by Sample and BEHAVIOR 
a <- ggplot (df, aes( x = fct_rev(CATEGORY), fill = MAKER_ID)) + 
  geom_bar(position = "fill") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# MAKER_CONFIDENCE by IDENTIFICATION  
b <- ggplot(df, aes( x = fct_rev(CATEGORY), y = MAKER_CONF, color = MAKER_ID)) + 
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_viridis(discrete=TRUE, option="viridis") +
  # labs (title = "MAKER-ID-CONFIDENCE") +
  labs (x = "STIMULUS CATEGORY") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER ID & CONFIDENCE',
  subtitle = '',
  caption = ''))

rm(a,b,p)

###################################################

3.2 MAKER AGE

3.2.1 Maker Age by Stimulus

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = fct_rev(STIMULUS), fill = MAKER_AGE)) +
  geom_bar(position = "fill") +
  #SCALES & SPACE FREE SUPPRESSES EMPTY ROWS
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  labs( title = "MAKER AGE by Stimulus (grouped by CATEGORY) ",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  coord_flip()+
  # easy_add_legend_title("") +
  theme_minimal()

3.2.2 Maker Age by Category

df <- df_graphs 

#MAKER AGE
ggplot( df, aes( x = CATEGORY, fill = MAKER_AGE)) +
  geom_bar(position = "stack") +
  labs( title = "MAKER AGE by Stimulus Category",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid(rows= vars(D_age)) +
  coord_flip()+
  theme_minimal()

3.2.3 Maker Age & Confidence by Stimulus

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER ID AND CONFIDENCE ##############
# MAKER_ID by Sample and BEHAVIOR 
a <- ggplot (df, aes( x = fct_rev(STIMULUS), fill = MAKER_AGE)) + 
  geom_bar(position = "fill", width = 0.8) +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# MAKER_CONFIDENCE by IDENTIFICATION  
b <- ggplot(df, aes( x = fct_rev(STIMULUS), y = MAKER_CONF, color = MAKER_AGE)) + 
  geom_boxplot(position=position_dodge(0.9), width = 0.5)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_viridis(discrete=TRUE, option="viridis") +
  labs (title = "") +
  labs (x = "STIMULUS CATEGORY") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER AGE & CONFIDENCE by Category',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.2.4 Maker Age & Confidence by Category

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER ID AND CONFIDENCE ##############
# MAKER_AGE by Sample and BEHAVIOR 
a <- ggplot (df, aes( x = fct_rev(CATEGORY), fill = MAKER_AGE)) + 
  geom_bar(position = "fill") + #dodge
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# MAKER_CONFIDENCE by IDENTIFICATION  
b <- ggplot(df, aes( x = fct_rev(CATEGORY), y = AGE_CONF, color = MAKER_AGE)) + 
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_viridis(discrete=TRUE, option="viridis") +
  labs (x = "STIMULUS CATEGORY") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER AGE & CONFIDENCE by Category',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.3 MAKER GENDER

3.3.1 Maker Gender by Stimulus

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = fct_rev(STIMULUS), fill = MAKER_GENDER)) +
  geom_bar(position = "fill") +
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  labs( title = "MAKER GENDER by Stimulus (grouped by CATEGORY) ",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  coord_flip()+
  # easy_add_legend_title("") +
  theme_minimal()

### Maker Gender by Category

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = CATEGORY, fill = MAKER_GENDER)) +
  geom_bar(position = "stack") +
  labs( title = "MAKER GENDER by Stimulus Category",
        subtitle = "", x = "") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid(rows= vars(D_age)) +
  coord_flip()+
  theme_minimal()

3.3.2 Maker Gender & Confidence by Stimulus

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER ID AND CONFIDENCE ##############
# MAKER_GENDER by STIMULUS
a <- ggplot (df, aes( x = fct_rev(STIMULUS), fill = MAKER_GENDER)) + 
  geom_bar(position = "fill", width = 0.8) +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# GENDER_CONFIDENCE by STIMULUS
b <- ggplot(df, aes( x = fct_rev(STIMULUS), y = GENDER_CONF, color = MAKER_GENDER)) + 
  geom_boxplot(position=position_dodge(0.9), width = 0.5)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_viridis(discrete=TRUE, option="viridis") +
  labs (x = "STIMULUS") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER GENDER & CONFIDENCE by Stimulus',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.3.3 Maker Gender & Confidence by Category

#FILTER DATAFRAME
df <- df_graphs 

######### MAKER GENDER AND CONFIDENCE ##############
a <- ggplot (df, aes( x = fct_rev(CATEGORY), fill = MAKER_GENDER)) + 
  geom_bar(position = "fill") +
  scale_fill_viridis(discrete=TRUE, option="viridis") +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  theme_minimal() 

# GENDER_CONFIDENCE by GENDER  
b <- ggplot(df, aes( x = fct_rev(CATEGORY), y = GENDER_CONF, color = MAKER_GENDER)) + 
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_viridis(discrete=TRUE, option="viridis") +
  labs (x = "STIMULUS CATEGORY") + 
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'MAKER GENDER & CONFIDENCE by Category',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.4 TOOL CHOICE

3.4.1 Tool ID by Stimulus

df <- df_tools 

# TOOL CHOICE BY STIMULUS
ggplot(data = df, aes( fill = fct_rev(TOOL_ID), x = fct_rev(STIMULUS) )) +
  geom_bar(position = "fill") +
  coord_flip() + 
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  scale_fill_paletteer_d("awtools::a_palette", direction = 1)+
  scale_y_continuous(labels = scales::percent) + 

  labs( title = "TOOL ID by Stimulus (grouped by Category)",
        subtitle = "", x = "") +
  easy_add_legend_title("TOOL_ID") +
  theme_minimal() 

3.4.2 Tool ID by Category

df <- df_tools 

# TOOL CHOICE BY STIMULUS
ggplot(data = df, aes( fill = fct_rev(TOOL_ID), x = CATEGORY )) +
  geom_bar(position = "fill") +
  coord_flip() + 
  scale_fill_paletteer_d("awtools::a_palette", direction = 1)+
  scale_y_continuous(labels = scales::percent) + 
  labs( title = "TOOL ID by Category",
        subtitle = "", x = "") +
  easy_add_legend_title("TOOL_ID") +
  theme_minimal() 

3.4.3 Tool ID & Confidence by Stimulus

#FILTER DATAFRAME
df <- df_tools 

######### TOOL ID AND CONFIDENCE ##############
a <- ggplot (df, aes( x = fct_rev(STIMULUS), fill = fct_rev(TOOL_ID))) + 
  geom_bar(position = "fill", width = 0.8) +
  scale_fill_paletteer_d("awtools::a_palette", direction = 1) +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") +
  easy_add_legend_title("TOOL ID")+
  theme_minimal() 

# TOOL_CONFIDENCE by STIMULUS
b <- ggplot(df, aes( x = fct_rev(STIMULUS), y = TOOL_CONF, color = fct_rev(TOOL_ID))) + 
  geom_boxplot(position=position_dodge(0.9), width = 0.6)+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_paletteer_d("awtools::a_palette", direction = 1) +
  labs (x = "STIMULUS") + 
  easy_add_legend_title("TOOL ID")+
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'TOOL ID & CONFIDENCE by Stimulus',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.4.4 Tool ID & Confidence by Category

#FILTER DATAFRAME
df <- df_tools 

######### TOOL ID AND CONFIDENCE ##############
a <- ggplot (df, aes( x = fct_rev(CATEGORY), fill = fct_rev(TOOL_ID))) + 
  geom_bar(position = "fill") +
  scale_fill_paletteer_d("awtools::a_palette", direction = 1) +
  # facet_grid( df$ENCOUNTER) + 
  labs (x = "") + 
  easy_add_legend_title("TOOL ID")+
  theme_minimal() 

# TOOL CONF 
b <- ggplot(df, aes( x = fct_rev(CATEGORY), y = TOOL_CONF, color = fct_rev(TOOL_ID))) + 
  geom_boxplot(position=position_dodge(0.9))+
  geom_jitter(position=position_jitterdodge(), alpha = 0.2) + 
  scale_color_paletteer_d("awtools::a_palette", direction = 1) +
  labs (x = "STIMULUS CATEGORY") + 
  easy_add_legend_title("TOOL ID")+
  theme_minimal() 

(p <- (a / b )  + plot_annotation(
  title = 'TOOL ID & CONFIDENCE by Category',
  subtitle = '',
  caption = ''))

###################################################

rm(a,b,p)

3.5 ENCOUNTER CHOICE

3.5.1 Encounter Choice by Stimulus

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = fct_rev(STIMULUS), fill = ENCOUNTER)) +
  geom_bar(position = "fill") +
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  labs( title = "MAKER ENCOUNTER by Stimulus (grouped by CATEGORY) ",
        subtitle = "", x = "") +
  scale_fill_brewer(palette = "Dark2") + 
  # scale_fill_viridis(discrete=TRUE, option="viridis", direction = -1) +
  coord_flip()+
  # easy_add_legend_title("") +
  theme_minimal()

3.5.2 Encounter Choice by Category

df <- df_graphs 

#MAKER IDENTIFICATION
ggplot( df, aes( x = CATEGORY, fill = ENCOUNTER)) +
  geom_bar(position = "stack") +
  labs( title = "ENCOUNTER by Stimulus Category (grouped by CATEGORY)",
        subtitle = "", x = "") +
  scale_fill_brewer(palette = "Dark2") + 
  coord_flip()+
  theme_minimal()

3.6 ACTIONS CHOICE

3.6.1 Actions Choice by Stimulus

df <- df_actions 

# ACTION CHOICE BY STIMULUS
ggplot(data = df, aes( fill = CHART_ACTION, x = fct_rev(STIMULUS) )) +
  geom_bar(position = "fill") +
  coord_flip() + 
  facet_grid(fct_rev(CATEGORY) ~ ., scales = "free", space = "free") + 
  scale_fill_paletteer_d("awtools::a_palette", direction = 1)+
  scale_y_continuous(labels = scales::percent) + 

  labs( title = "Chart Action by Stimulus (grouped by Category)",
        subtitle = "", x = "") +
  easy_add_legend_title("ACTION") +
  theme_minimal() 

3.6.2 Actions Choice by Category

df <- df_actions 

# ACTION CHOICE BY STIMULUS
ggplot(data = df, aes( fill = CHART_ACTION, x = CATEGORY )) +
  geom_bar(position = "fill") +
  coord_flip() + 
  scale_fill_paletteer_d("awtools::a_palette", direction = 1)+
  scale_y_continuous(labels = scales::percent) + 
  labs( title = "CHART ACTION by Category",
        subtitle = "", x = "") +
  easy_add_legend_title("ACTION") +
  theme_minimal() 

4 INTERACTIVE GRAPHS

4.0.1 WIP IXN Maker ID & Politics

#SETUP LISTS 
stim <- ref_stimuli
plots_maker_politics <- htmltools::tagList()

### MAKE PLOTS 
# LOOP THROUGH STIMULI
i = 0
for (s in stim){
  i = i+1 #iterator hack
  
  d <- df_graphs_full %>% filter(STIMULUS == s) %>% select(ID.Prolific, STIMULUS, 
                                                               MAKER_ID, MAKER_DETAIL, MAKER_CONF, MAKER_POLITIC,
                                                               D_politicalParty, D_politicsSocial, D_politicsFiscal) 
  p <- ggplot(d, aes(x = MAKER_POLITIC, y = MAKER_CONF,
          color = MAKER_ID ,
          text = paste0("MAKER-DETAIL: ",MAKER_DETAIL, "<br>","ID: ", ID.Prolific)))+
      geom_point() +
      xlim(0,100)+
      ylim(0,100)+
      facet_grid(MAKER_ID  ~ D_politicalParty) +
      theme_minimal() +
      labs(
        title = paste(s," | ", "MAKER Identification, Politics and Confidence, by Participant Confidence and Political Affiliation"),
        x = "MAKER POLITICS",
        y = "MAKER CONFIDENCE"
      )

  
  plots_maker_politics[[i]] <- ggplotly(p)
  
}

names(plots_maker_politics) <- ref_stimuli


#works in console but not render 
### PRINT PLOTS
# for (s in stim){
#   print(plots_maker_politics[[s]])
# }


# ggplotly(p) #works for single

plots_maker_politics

5 ALL SEMANTIC DIFFERENTIAL QUESTIONS

5.1 ALL QUESTIONS

5.1.1 ALL Q BY STIMULUS

##ONLY RENDER GRAPHS IF SET TO TRUE
if(graph_render == TRUE){


#################### ALL QUESTIONS AT STIMULUS #####################
# ONE PLOT FOR EACH STIMULUS WITH ALL QUESTIONS

#set stimuli to be graphed 
stimuli <- ref_stimuli #created in wrangling block
# stimili <- c("B0-0","B2-1" ,"B2-2", "B2-3", "B2-4")

plots_stimulus <- list()
i = 0
for (s in stimuli){
  i = i+1
  
  # setup dataframe 
  title <- df_stimuli %>% filter(ID == s) %>% select(NAME) 
  title <- paste(s,"|",title)
  df <- df_graphs %>% filter(STIMULUS== s)

  #subset data cols 
  cols <- df %>% select( all_of(ref_sd_questions))
  plots <- as.list(lapply(colnames(cols), plot_sd, data = df, type ="S", boxplot=TRUE))

  #aggregate q plots into one for stimulus 
  x <- plots[[1]] / plots[[2]] / plots[[3]] / plots[[4]] / plots[[5]] / plots[[6]] / plots[[7]] /
   plots[[8]] /plots[[9]] /plots[[10]] /plots[[11]] + 
   plot_annotation(
     title = title,
     subtitle =""
   )
  
  plots_stimulus[[i]] <- x
  ggsave(plot = x, path="figs/all_q_by_stimulus", filename =paste0(s,".png"), units = c("in"), width = 10, height = 14  )
}

#GIVE NAMES TO LIST
#NOW CAN ACCESS plots by plots_stimulus$`B1-1`
#ALSO plots_stimulus$`B1-1`[[1]]
names(plots_stimulus) <- stimuli
rm(x, i, plots)

#############################################################################
} 

5.1.1.1 WIP ALT SD GRAPHS

# # library
# library(ggdist)
# library(ggridges)
# 
# #RIDGEPLOT
# ##ALL QUESTIONS FOR STIMULUS 1
# 
# s = "B0-0"
# df <- df_sd_questions %>% select(1:6, s) %>% filter(!is.na(s)) %>%  mutate(
#   value = `B0-0`
# )
# 
# ggplot(df, aes(x = value, y = QUESTION, fill = QUESTION)) +
#   geom_density_ridges(scale=0.9) +
#   # xlim(0,100)+
#   theme_ridges() + 
#   theme(legend.position = "none")
# 
# 
# 
# 
# library(ggdist)
# 
# d <- df %>% filter(str_detect(QUESTION,"CHART_"))
# 
# ggplot(df, aes(y = QUESTION, x = value, fill = QUESTION)) +
#   stat_slab(aes(thickness = after_stat(pdf*n)), scale = 0.7) +
#   stat_dotsinterval(side = "bottom", scale = 0.7, slab_linewidth = NA) +
#   theme_minimal()
# 

5.1.2 ALL Q BY CATEGORY

##ONLY RENDER GRAPHS IF SET TO TRUE
if(graph_render == TRUE){

#################### ALL QUESTIONS AT CATEGORY #####################
# ONE PLOT FOR EACH CATEGORY WITH ALL QUESTIONS

#set questions to be graphed 
categories <- unique(df_graphs$CATEGORY)#created in wrangling block
plots_category <- list()
i = 0
for (c in categories){
  i = i+1

  # setup dataframe
  title <- paste("STIMULUS CATEGORY ", c)
  df <- df_graphs %>% filter(CATEGORY == c)
  
  #subset data cols
  cols <- df %>% select( all_of(ref_sd_questions))
  plots <- as.list(lapply(colnames(cols), plot_sd, data = df, type = "S", boxplot=TRUE))
  
  #aggregate stimulus plots into block for question
  x <- plots[[1]] / plots[[2]]  / plots[[3]] / plots[[4]] / plots[[5]] / plots[[6]] / plots[[7]] /
        plots[[8]] /plots[[9]] /plots[[10]] /plots[[11]] +
      plot_annotation(
        title = title,
       subtitle =""
      )

  plots_category[[i]] <- x
  ggsave(plot = x, path="figs/all_q_by_category", filename =paste0(c,".png"), units = c("in"), width = 10, height = 26)
  
}  

#GIVE NAMES TO LIST
#NOW CAN ACCESS plots by plots_category$A
#ALSO plots_category$A[[1]]
names(plots_category) <- categories
rm(x, i, plots)

}

5.2 BY QUESTION

5.2.1 Q for ALL STIMULI

##ONLY RENDER GRAPHS IF SET TO TRUE
if(graph_render == TRUE){

####################CREATE SD PLOTS FOR EACH QUESTION#####################

#set questions to be graphed 
questions <- ref_sd_questions  #created in wrangling block
plots_s_question <- list()
i = 0
for (q in questions){
  i = i+1
  
  # setup dataframe 
  title <- paste(q)
  df <- df_sd_questions %>% filter(QUESTION == q)

  #subset data cols 
  c <- df %>% select( all_of(ref_stimuli))
  plots <- as.list(lapply(colnames(c), plot_sd, data = df, type = "Q", boxplot=TRUE))
  
  #aggregate stimulus plots into block for question
  x <- plots[[1]] / plots[[2]]  / plots[[3]] / plots[[4]] / plots[[5]] / plots[[6]] / plots[[7]] /
        plots[[8]] /plots[[9]] /plots[[10]] /plots[[11]] /  plots[[12]] / plots[[13]] / plots[[14]] / 
        plots[[15]] /plots[[16]] /plots[[17]] /plots[[18]] /  plots[[19]] / plots[[20]] / plots[[21]] /
        plots[[22]] /plots[[23]] /plots[[24]] /plots[[25]] + 
      plot_annotation(
        title = title,
       subtitle =""
      )
  plots_s_question[[i]] <- x 
  ggsave(plot = x, path="figs/by_q_for_all_stimuli", filename =paste0(q,".png"), units = c("in"), width = 10, height = 26)
}

#GIVE NAMES TO LIST
#NOW CAN ACCESS plots by plots_s_question$MAKER_DESIGN
#ALSO plots_s_question$MAKER_DESIGN[[1]]
names(plots_s_question) <- questions
rm(x, i, plots)

#############################################################################

}

5.2.2 Q for ALL CATEGORIES

##ONLY RENDER GRAPHS IF SET TO TRUE
if(graph_render == TRUE){
  
####################SD PLOTS QUESTION BY CATEGORY #####################

#set grouping column 
g = "CATEGORY" #string name of column to group by 

#set questions to be graphed 
questions <- ref_sd_questions#created in wrangling block
plots_c_question <- list()

i = 0
for (q in questions){
  i = i+1
  left <-   ref_labels[q,]$left
  right <-  ref_labels[q,]$right
  
  # setup dataframe 
  title <- paste(q," BY CATEGORY")
  df <- df_graphs 
  
  x <- multi_sd(df, left, right, x = q, y = g, color = g) + 
      labs(title  = q) 
 
  plots_c_question[[i]] <- x
  ggsave(plot = x, path="figs/by_q_for_all_categories", filename =paste0(q,".png"))
}

#GIVE NAMES TO LIST
#NOW CAN ACCESS plots by plots_c_question$MAKER_DESIGN
#ALSO plots_c_question$MAKER_DESIGN[[1]]
names(plots_c_question) <- questions
rm(x, i)
  
#############################################################################

}

6 LEGACY

# #### 
# q = "MAKER_DESIGN"
# df <- df_questions %>% filter(QUESTION == q) %>% 
#   mutate(
#     value = as.numeric(value),
#     CATEGORY = str_remove(STIMULUS,"B.-"),
#     CATEGORY = factor(CATEGORY,
#                   levels=c("0","1","2","3","4"),
#                   labels= c("F","A","B","C","D"))
# )
# 
# 
# g <- ggplot(df, aes(y = value, x="", color = CATEGORY)) +
#     geom_boxplot(width = 0.5)+
#     geom_jitter(width = 0.1, alpha=0.3) + 
#     scale_y_continuous(limits=c(-1,101)) +
#     labs(x="", y="") +
#     coord_flip()  +
#     facet_grid(df$CATEGORY ~ .) + 
#     labs(title=df$CATEGORY) + 
#     guides(
#         y = guide_axis_manual(labels = ref_labels[q,"left"]),
#         y.sec = guide_axis_manual(labels = ref_labels[q,"right"])
#       ) +  
#   theme_minimal()  + 
#   labs (title = q)
# 
# g
# left <- rep(ref_labels[q,"left"], length(unique(df$CATEGORY)))
# right <- rep(ref_labels[q,"left"], length(unique(df$CATEGORY)))
# a <- multi_sd(df, x = value, y = QUESTION, color = CATEGORY, left=, right=right)
# 
# 
# multi_sd <- function (df, x, y, color, left,right) { 
#   
#   g <- ggplot(df, aes(y = {{x}}, x = {{y}}, color = {{color}}))+
#   geom_boxplot(width = 0.5) + 
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   facet_grid(rows=vars({{color}})) +
#   labs(x="", y="") +
#   coord_flip() + 
#   guides(
#     y = guide_axis_manual(labels = left),
#     y.sec = guide_axis_manual(labels = right)
#   ) + theme_minimal() 
#   
#   return(g)
# }




# ## GROUPED PLOTSD FUNCTION 
# grouped_plotsd = function (data, x, type, q, boxplot) {
#   ggplot(df, aes(y = .data[[x]], x="")) +
#     {if(boxplot) geom_boxplot(width = 0.5) } +
#     geom_jitter(width = 0.1, alpha=0.3) + 
#     scale_y_continuous(limits=c(-1,101)) +
#     labs(x="", y="") +
#     coord_flip()  +
#     {if(type == "Q")
#       guides(
#         y = guide_axis_manual(labels = ref_labels[q,"left"]),
#         y.sec = guide_axis_manual(labels = ref_labels[q,"right"])
#       )} +  
#   theme_minimal()  + 
#      labs (
#        caption = column
#      )
# }


#####################################################################

# # stim <- "B1-1"
# 
# # setup dataframe 
# title <- df_stimuli %>% filter(ID ==stim) %>% select(NAME) 
# title <- paste(stim,"|",title)
# df <- df_graphs %>% filter(STIMULUS==stim)
# 
# #subset data cols 
# d <- df %>% select( all_of(questions))
# plots <- as.list(lapply(colnames(d), plotsd, data = df, boxplot=TRUE))
# 
# ## PICK UP HERE, FIGURE OUT HOW TO LOOP OVER STIM
# 
# x <- plots[[1]] / plots[[2]] / plots[[3]] / plots[[4]] / plots[[5]] / plots[[6]] / plots[[7]] /
#   plots[[8]] /plots[[9]] /plots[[10]] /plots[[11]] + 
#   plot_annotation(
#     title = title,
#     subtitle =""
#   )
# x
# ggsave(plot = x, filename =paste(stim,".png"), units = c("in"), width = 10, height = 14  )




#CREATE MATRIX 
# m <- matrix(nrow = length(stim), ncol = length(questions)) 
# rownames(m) <- stim
# colnames(m) <- questions

6.1 LEGACY

7 MODELLING

##STATSPLOT
# grouped_ggwithinstats(
#   data  = df_graphs,
#   x     = STIMULUS,
#   y     = CHART_TRUST,
#   grouping.var = ID.Study
# ) 

# grouped_ggscatterstats(
#   data = df_graphs, ## data frame from which variables are taken
#   x = CHART_BEAUTY, ## predictor/independent variable
#   y = CHART_TRUST, ## dependent variable
#   grouping.var = ID.Study,
#   xlab = "CHART BEAUTY", ## label for the x-axis
#   ylab = "CHART TRUST", ## label for the y-axis
#   # label.expression = rating < 5 & budget > 100, ## expression for deciding which points to label
#   point.label.args = list(alpha = 0.7, size = 4, color = "grey50"),
#   xfill = "#CC79A7", ## fill for marginals on the x-axis
#   yfill = "#009E73" ## fill for marginals on the y-axis
#   # title = "CHART TRUST (VS) MAKER TRUST",
#   # caption = ""
# )
# 
# gf_point( data = df_graphs, CHART_TRUST~MAKER_TRUST, color = ~STIMULUS) %>% gf_facet_wrap(~STIMULUS)
# 
# 
# grouped_ggscatterstats(
#   data = df_graphs, ## data frame from which variables are taken
#   x = MAKER_TRUST, ## predictor/independent variable
#   y = CHART_TRUST, ## dependent variable
#   grouping.var = ID.Study,
#   xlab = "MAKER TRUST", ## label for the x-axis
#   ylab = "CHART TRUST", ## label for the y-axis
#   # label.expression = rating < 5 & budget > 100, ## expression for deciding which points to label
#   point.label.args = list(alpha = 0.7, size = 4, color = "grey50"),
#   xfill = "#CC79A7", ## fill for marginals on the x-axis
#   yfill = "#009E73" ## fill for marginals on the y-axis
#   # title = "CHART TRUST (VS) MAKER TRUST",
#   # caption = ""
# )
# 
# gf_point( data = df_graphs, MAKER_TRUST~CHART_TRUST, color = ~STIMULUS) %>% gf_facet_wrap(~STIMULUS)
# 
# 
# 
# grouped_ggscatterstats(
#   data = df_graphs, ## data frame from which variables are taken
#   x = CHART_BEAUTY, ## predictor/independent variable
#   y = MAKER_ALIGN, ## dependent variable
#   grouping.var = ID.Study,
#   xlab = "CHART BEAUTY", ## label for the x-axis
#   ylab = "MAKER ALIGN", ## label for the y-axis
#   # label.expression = rating < 5 & budget > 100, ## expression for deciding which points to label
#   point.label.args = list(alpha = 0.7, size = 4, color = "grey50"),
#   xfill = "#CC79A7", ## fill for marginals on the x-axis
#   yfill = "#009E73" ## fill for marginals on the y-axis
#   # title = "CHART TRUST (VS) MAKER TRUST",
#   # caption = ""
# )
# 
# 
# gf_point( data = df_graphs, MAKER_ALIGN~CHART_BEAUTY, color = ~STIMULUS) %>% gf_facet_wrap(~STIMULUS)
# 
# 
# 
# 
# 
# 
# ggscatterstats(
#   data = df_graphs %>% filter(STIMULUS=="B0-0"), ## data frame from which variables are taken
#   x = CHART_BEAUTY, ## predictor/independent variable
#   y = MAKER_TRUST, ## dependent variable
#   xlab = "CHART BEAUTY", ## label for the x-axis
#   ylab = "MAKER TRUST", ## label for the y-axis
#   # label.expression = rating < 5 & budget > 100, ## expression for deciding which points to label
#   point.label.args = list(alpha = 0.7, size = 4, color = "grey50"),
#   xfill = "#CC79A7", ## fill for marginals on the x-axis
#   yfill = "#009E73" ## fill for marginals on the y-axis
#   # title = "CHART TRUST (VS) MAKER TRUST",
#   # caption = ""
# )
# 
# gf_point( data = df_graphs %>% filter(STIMULUS=="B0-0"), CHART_TRUST~CHART_BEAUTY, color = ~STIMULUS) %>% gf_facet_wrap(~STIMULUS)
# 
# gf_point( data = df_graphs %>% filter(STIMULUS=="B0-0"), MAKER_TRUST~CHART_BEAUTY, color = ~STIMULUS) %>% gf_facet_wrap(~STIMULUS)
# 
# 
# #TODO CENTERING AND NORMALIZING
# 
# ### little model
# df <- df_graphs %>% filter(STIMULUS == "B0-0")
# m <- lm( CHART_TRUST ~ CHART_BEAUTY,data = df)
# summary(m)
# ggnostic(m) #GGALLY MODEL CHECKS
# check_model(m) #EASY STATS MODEL CHECKS 
# 
# report(m)
### MORE COMPLEX MODEL
# df <- df_graphs %>% filter(STIMULUS != "B0-0")
# m1 <- lmer(CHART_TRUST ~ CHART_BEAUTY + (1|ID.Qualtrics), data = df)
# m2 <- lmer(CHART_TRUST ~ CHART_BEAUTY + (1|STIMULUS), data = df)
# m3 <- lmer(CHART_TRUST ~ CHART_BEAUTY + (1 | STIMULUS) + (1 | ID.Qualtrics), data = df)
# summary(m1)
# summary(m2)
# summary(m3)
# compare_parameters(m1,m2,m3)
# compare_performance(m1,m2,m3, rank = TRUE)
# 
# 
# m <- lmer(CHART_TRUST ~ CHART_BEAUTY + MAKER_TRUST + (1 | STIMULUS) ,  data = df)
# mi <- lmer(CHART_TRUST ~ CHART_BEAUTY * MAKER_TRUST + (1 | STIMULUS) , data = df)
# summary(m)
# summary(mi)
# 
# compare_performance(m3,m,mi, rank = TRUE)
# 
# report(m)
#todo see https://yury-zablotski.netlify.app/post/mixed-effects-models-2/ about fitting with ML vs REML for model comparison 
# #TODO WALK THROUGH THIS 
# #https://yury-zablotski.netlify.app/post/mixed-models/#multiple-random-slope-model
# 
# #load example data
# data("sleepstudy")
# 
# #fit the model
# m_slp <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
# 
# #the next line put all the estimated intercept and slope per subject into a dataframe
# reaction_slp <- as.data.frame(t(apply(ranef(m_slp)$Subject, 1,function(x) fixef(m_slp) + x)))
# 
# #to get the predicted regression lines we need one further step, writing the linear equation: Intercept + Slope*Days with different coefficient for each subject
# pred_slp <- melt(apply(reaction_slp,1,function(x) x[1] + x[2]*0:9), value.name = "Reaction")
# 
# #some re-formatting for the plot
# names(pred_slp)[1:2] <- c("Days","Subject")
# pred_slp$Days <- pred_slp$Days - 1
# pred_slp$Subject <- as.factor(pred_slp$Subject)
# 
# #plot with actual data 
# ggplot(pred_slp,aes(x=Days,y=Reaction,color=Subject))+
#   geom_line()+
#   geom_point(data=sleepstudy,aes(x=Days,y=Reaction))+
#   facet_wrap(~Subject,nrow=3)

8 STASH

8.0.1 COLOR palettes

#DISPLAY COLOR PALETTE
#display.brewer.pal(n = 8, name = 'Dark2')

#DISPLAY COLOR PALETTE
# paletteer_d("Redmonder::dPBIPuGn")

8.0.2 DISTRIBUTION plots

# #SET UP DATAFRAME
# df <- df_data
# 
# ## DENSITY HISTOGRAPH
# ggplot(data = df_data, aes( x = duration.min, fill = Assigned.Block)) +
#   geom_density(alpha = 0.5) +
#   facet_grid(rows = vars(Assigned.Block)) +
#   labs( x = "Survey Response Time (mins)",
#         title = "TOTAL Response Time by Sample",
#         subtitle = "(expect similiar across samples)") +
#   easy_add_legend_title("Sample") +
#   theme_minimal()
# 
# 
# ## RAINCLOUD
# ggplot(df, aes(x = duration.min, y = fct_rev(Assigned.Block), fill = fct_rev(Assigned.Block))) +
#   stat_slab(aes(thickness = after_stat(pdf*n), alpha=0.5), scale = 0.7) +
#   stat_dotsinterval(side = "bottom", scale = 0.7, slab_linewidth = NA) +
#   scale_fill_discrete(direction=-1)+
#   xlim(0,225) +
#   labs( x = "Survey Response Time (mins)", y="",
#         title = "TOTAL Response Time by Sample",
#         subtitle = "(expect similiar across samples)") +
#   theme_minimal() +
#   easy_remove_legend()
# 
# 
# ##RIDGEPLOT
# ggplot(df, aes(x = duration.min, y = fct_rev(Assigned.Block), fill = fct_rev(Assigned.Block))) +
#   geom_density_ridges(scale=0.9) +
#   # geom_boxplot()+
#   stat_pointinterval()+
#   theme_ridges() +
#   scale_fill_discrete(direction=-1)+
#   theme(legend.position = "none") +
#     labs( x = "Survey Response Time (mins)", y="",
#         title = "TOTAL Response Time by Sample",
#         subtitle = "(expect similiar across samples)")

8.0.3 all-q for stimulus

# s = "B0-0" #stimulus code
# t = "STIMULUS B0 — MILLENIAL PINK PLANTS" #STIMULUS TITLE
# 
# #FILTER DATAFRAME
# df <- df_graphs %>% filter(STIMULUS == s)
# 
# 
# #BUILD SEMANTIC DIFFERENTIALS
# m_design <- single_sd(df, "professional", "layperson", x = MAKER_DESIGN) +
#       labs(title  = "MAKER-DESIGN") +
#       easy_remove_legend()
# 
# m_data <- single_sd(df, "professional", "layperson", x = MAKER_DATA) +
#       labs(title  = "MAKER-DATA") +
#       easy_remove_legend()
# 
# m_politics <- single_sd(df, "left-leaning", "right-leaning", x = MAKER_POLITIC) +
#       labs(title  = "MAKER-POLITICS") +
#       easy_remove_legend()
# 
# m_argue <- single_sd(df, "confrontational", "diplomatic", x = MAKER_ARGUE) +
#       labs(title  = "MAKER-ARGUE") +
#       easy_remove_legend()
# 
# m_selfish <- single_sd(df, "altruistic", "selfish", x = MAKER_SELF) +
#       labs(title  = "MAKER-SELFISH") +
#       easy_remove_legend()
# 
# m_align <- single_sd(df, "does NOT share", "does share", x = MAKER_ALIGN) +
#       labs(title  = "MAKER-ALIGNMENT") +
#       easy_remove_legend()
# 
# m_trust <- single_sd(df, "untrustworthy", "trustworthy", x = MAKER_TRUST) +
#       labs(title  = "MAKER-TRUST") +
#       easy_remove_legend()
# 
# 
# #BUILD MASTER PLOT
# PLOT_maker <- (m_design / m_data / m_politics / m_argue / m_selfish / m_align / m_trust) +
#   plot_annotation(
#     title = t,
#     subtitle =""
#   )
# 
# PLOT_maker

8.0.4 all-q for stimulus - grouped

#  s = "B0-0" #stimulus code
#  t = "STIMULUS B0 — MILLENIAL PINK PLANTS" #STIMULUS TITLE
#  g = "Assigned.Block"
#  ##can also use y and color to split by additional variable 
#  
#  #FILTER DATAFRAME
#  df <- df_graphs %>% filter(STIMULUS == s)
# 
#  #BUILD SEMANTIC DIFFERENTIALS
#  m_design <- multi_sd(df, "professional", "layperson", x = "MAKER_DESIGN", y = g, color = g) +
#        labs(title  = "MAKER-DESIGN") +
#        easy_remove_legend()
# 
#  m_data <- multi_sd(df, "professional", "layperson", x = "MAKER_DATA", y = g, color = g) +
#        labs(title  = "MAKER-DATA") +
#        easy_remove_legend()
# 
#  m_politics <- multi_sd(df, "left-leaning", "right-leaning", x = "MAKER_POLITIC", y = g, color = g) +
#        labs(title  = "MAKER-POLITICS") +
#        easy_remove_legend()
# 
#  m_argue <- multi_sd(df, "confrontational", "diplomatic", x = "MAKER_ARGUE", y = g, color = g) +
#        labs(title  = "MAKER-ARGUE") +
#        easy_remove_legend()
# 
#  m_selfish <- multi_sd(df, "altruistic", "selfish", x = "MAKER_SELF", y = g, color = g) +
#        labs(title  = "MAKER-SELFISH") +
#        easy_remove_legend()
# 
#  m_align <- multi_sd(df, "does NOT share", "does share", x = "MAKER_ALIGN", y = g, color = g) +
#        labs(title  = "MAKER-ALIGNMENT") +
#        easy_remove_legend()
# 
#  m_trust <- multi_sd(df, "untrustworthy", "trustworthy", x = "MAKER_TRUST", y = g, color = g) +
#        labs(title  = "MAKER-TRUST") 
# 
# 
#  #BUILD MASTER PLOT
#  PLOT_maker <- (m_design / m_data / m_politics / m_argue / m_selfish / m_align / m_trust) +
#    plot_annotation(
#      title = t,
#      subtitle =""
#    )
# 
#  PLOT_maker

8.0.5 across Blocks

######### MAKER ATTRIBUTES ########################
# vals = c("datacollar", "bluecollar")
# leftside <- rep ("PROFESSIONAL",n_blocks )
# rightside <-rep ("LAYPERSON",n_blocks ) 
# b00_m_design <- ggplot(df, aes(y = MAKER_DESIGN, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DESIGN")

# b00_m_data <- ggplot(df, aes(y = MAKER_DATA, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DATA")


# leftside <- rep ("LEFT-WING",n_blocks )
# rightside <-rep ("RIGHT-WING",n_blocks ) 
# b00_m_politics <- ggplot(df, aes(y = MAKER_POLITIC, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-POLITICS")
  

# leftside <- rep ("CONFRONTATIONAL",n_blocks )
# rightside <-rep ("DIPLOMATIC",n_blocks ) 
# b00_m_argue <- ggplot(df, aes(y = MAKER_ARGUE, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-ARGUE")
  
# leftside <- rep ("ALTRUSITC",n_blocks )
# rightside <-rep ("SELFISH",n_blocks ) 
# b00_m_selfish <- ggplot(df, aes(y = MAKER_SELF, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SELFISH")

# 
# leftside <- rep ("Does NOT",n_blocks )
# rightside <-rep ("DOES",n_blocks ) 
# b00_m_align <- ggplot(df, aes(y = MAKER_ALIGN, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SHARES-MY-VALUES")

# leftside <- rep ("UNTRUSTWORTHY",n_blocks )
# rightside <-rep ("TRUSTWORTHY",n_blocks ) 
# b00_m_trust <- ggplot(df, aes(y = MAKER_TRUST, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   # easy_remove_legend() +
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-TRUST")
# 
# PLOT_b0_maker <- (b00_m_design / b00_m_data / b00_m_politics / b00_m_argue / b00_m_selfish / b00_m_align / b00_m_trust) + 
#   plot_annotation(
#     title = "STIMULUS B0 — MILLENIAL PINK PLANTS",
#     subtitle =""
#   )
# 
# PLOT_b0_maker
###################################################

8.0.6 single Block

# #FILTER DATAFRAME
# df <- df_graphs %>% filter(STIMULUS == "B0-0")
# 
# ######### MAKER ATTRIBUTES ########################
# vals = c("datacollar", "bluecollar")
# leftside <- rep ("PROFESSIONAL",1 )
# rightside <-rep ("LAYPERSON",1 ) 
# b_m_design <- ggplot(df, aes(y = MAKER_DESIGN, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DESIGN")
# 
# b_m_data <- ggplot(df, aes(y = MAKER_DATA, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DATA")
# 
# 
# leftside <- rep ("LEFT-WING",1 )
# rightside <-rep ("RIGHT-WING",1 ) 
# b_m_politics <- ggplot(df, aes(y = MAKER_POLITIC, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-POLITICS")
#   
# 
# leftside <- rep ("CONFRONTATIONAL",1 )
# rightside <-rep ("DIPLOMATIC",1 ) 
# b_m_argue <- ggplot(df, aes(y = MAKER_ARGUE, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-ARGUE")
#   
# leftside <- rep ("ALTRUSITC",1 )
# rightside <-rep ("SELFISH",1 ) 
# b_m_selfish <- ggplot(df, aes(y = MAKER_SELF, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SELFISH")
# 
# 
# leftside <- rep ("Does NOT",1 )
# rightside <-rep ("DOES",1 ) 
# b_m_align <- ggplot(df, aes(y = MAKER_ALIGN, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SHARES-MY-VALUES")
# 
# leftside <- rep ("UNTRUSTWORTHY",1 )
# rightside <-rep ("TRUSTWORTHY",1 ) 
# b_m_trust <- ggplot(df, aes(y = MAKER_TRUST, x = ""))+
#   geom_boxplot(width = 0.5) +
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-TRUST")
# 
# 
# PLOT_b_maker <- (b_m_design / b_m_data / b_m_politics / b_m_argue / b_m_selfish / b_m_align / b_m_trust) + 
#   plot_annotation(
#     title = paste(unique(df$STIMULUS), "MAKER")
#   )
# 
# PLOT_b_maker
###################################################

8.0.7 single Block grouped

# 
# #FILTER DATAFRAME
# df <- df_graphs %>% filter(STIMULUS == "B0-0")
# 
# ######### MAKER ATTRIBUTES ########################
# vals = c("datacollar", "bluecollar")
# leftside <- rep ("PROFESSIONAL",1 )
# rightside <-rep ("LAYPERSON",1 ) 
# b_m_design <- ggplot(df, aes(y = MAKER_DESIGN, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DESIGN")
# 
# b_m_data <- ggplot(df, aes(y = MAKER_DATA, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-DATA")
# 
# 
# leftside <- rep ("LEFT-WING",1 )
# rightside <-rep ("RIGHT-WING",1 ) 
# b_m_politics <- ggplot(df, aes(y = MAKER_POLITIC, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-POLITICS")
#   
# 
# leftside <- rep ("CONFRONTATIONAL",1 )
# rightside <-rep ("DIPLOMATIC",1 ) 
# b_m_argue <- ggplot(df, aes(y = MAKER_ARGUE, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-ARGUE")
#   
# leftside <- rep ("ALTRUSITC",1 )
# rightside <-rep ("SELFISH",1 ) 
# b_m_selfish <- ggplot(df, aes(y = MAKER_SELF, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SELFISH")
# 
# 
# leftside <- rep ("Does NOT",1 )
# rightside <-rep ("DOES",1 ) 
# b_m_align <- ggplot(df, aes(y = MAKER_ALIGN, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-SHARES-MY-VALUES")
# 
# leftside <- rep ("UNTRUSTWORTHY",1 )
# rightside <-rep ("TRUSTWORTHY",1 ) 
# b_m_trust <- ggplot(df, aes(y = MAKER_TRUST, x = ID.Study, color = ID.Study))+
#   geom_jitter(width = 0.1, alpha=0.5) + 
#   scale_y_continuous(limits=c(-1,101)) +
#   labs(x="", y="") +
#   coord_flip() + 
#   theme_minimal() + 
#   easy_remove_legend() + 
#   guides(
#   y = guide_axis_manual(
#   #breaks = vals, 
#   labels = leftside  
#   ),
#   y.sec = guide_axis_manual(
#   #breaks = vals, 
#   labels = rightside
# )) + 
#   labs(title  = "MAKER-TRUST")
# 
# 
# PLOT_b_maker <- (b_m_design / b_m_data / b_m_politics / b_m_argue / b_m_selfish / b_m_align / b_m_trust) + 
#   plot_annotation(
#     title = paste(unique(df$STIMULUS), "MAKER")
#   )
# 
# PLOT_b_maker
# ###################################################